import BaseItemView from "../../../cfw/mvc/BaseItemView";
import ModuleManager, { ModuleID } from "../../../cfw/module/ModuleManager";
import { ResType } from "../../../cfw/res/ResInterface";
import ResItem from "../../../cfw/res/ResItem";
import DecorationControllerInterface from "../../../public/interface/DecorationControllerInterface";
import BaseItemModel from "../../../cfw/mvc/BaseItemModel";


const { ccclass, property } = cc._decorator;

@ccclass
export default class ClotheIconView extends BaseItemView {

    @property(cc.Sprite)
    icon: cc.Sprite = null;
    protected controller: DecorationControllerInterface;
    protected model: BaseItemModel;

    refresh(){
        ModuleManager.getLoader(ModuleID.LOBBY).loadRes(this.model.getIcon(), ResType.SpriteFrame, (err, res: ResItem) => {
            if (err || !cc.isValid(this.node)) {
                return;
            }
            this.icon.spriteFrame = res.getRes()
        })
    }

    onButtonClick() {
        this.controller.selectColumn(this.model)
    }
    // update (dt) {}
}
